Almost diagonalization of pseudodifferential operators