For any master equation which is local in time, whether Markovian, non-Markovian, of Lindblad form or not, a general procedure is given for constructing the corresponding linear map from the initial state to the state at time t, including its Kraus-type representations. Formally, this is equivalent to solving the master equation. For an N-dimensional Hilbert space it requires (i) solving a first order N²xN² matrix time evolution (to obtain the completely positive map), and (ii) diagonalizing a related N²xN² matrix (to obtain a Kraus-type representation). Conversely, for a given time-dependent linear map, a necessary and sufficient condition is given for the existence of a corresponding master equation, where the (not necessarily unique) form of this equation is explicitly determined. It is shown that a “best possible” master equation may always be defined, for approximating the evolution in the case that no exact master equation exists. Examples involving qubits are given.