Suppose we are working in an abelian category. Prove that any map $\displaystyle f: A \rightarrow B$ has a decomposition $\displaystyle A \rightarrow \mathrm{im}(f) \rightarrow B$ where the left arrow is epi and the right arrow is monic.

My attempt of solution

Let's consider cokernel of f: $\displaystyle \mathrm{coker}(f): B \rightarrow C$ it exists since we are in abelian category. For the same reason the cokernel has a kernel $\displaystyle \mathrm{ker coker}(f): \mathrm{im}(f) \rightarrow B$.

Since $\displaystyle \mathrm{coker}(f) \circ f = 0$ there is map $\displaystyle f': A \rightarrow \mathrm{im}(f)$ such that $\displaystyle f = \mathrm{ker coker}(f) \circ f'$. This is the factorization we were looking for.

Immediatly we see, that the right arrow is monic (since kernels are monics), so the only problem is to prove that $\displaystyle f'$ is epi. And this is the thing i cannot do

I was unable to prove that $\displaystyle \mathrm{coker}(f) = 0$ since i cannot see any nonzero arrows from $\displaystyle \mathrm{im}(f)$ (and I need such arrow in order to use cokernel universality property).

Yet I was able to see some things...

Let $\displaystyle m = \mathrm{ker coker}(f)$. One thing I was able to notice is that $\displaystyle \mathrm{coker}(m) = coker(f)$. It is obvious that we have to use property, that the rightmost arrow is a cokernel (we can do the above construction with any map for which composition with f is 0, but f' need not to be epi). However again I don't see any arrows from B (so i cannot use cokernel property).

I had some other idea to deal with it. Let us start "from the other side". So consider kernel of f: $\displaystyle \mathrm{ker}(f): K \rightarrow A$. The analogous construction yields decomposition $\displaystyle A \rightarrow \mathrm{cim}(f) \rightarrow B$ where the first arrow is $\displaystyle \mathrm{coker ker}(f)$ and the second one is denoted by $\displaystyle f''$.

I was able to construct a map $\displaystyle i: \mathrm{cim}(f) \rightarrow \mathrm{im}(f)$ which has good "composition properties" (the corresponding triangles are commutative), however i was unable to prove that $\displaystyle i$ is an isomorphism (i was unable to construct the arrow in the opposite direction).

I would appreciate any ideas concerning this problem.