I know this is an old question, but this came up recently in an answer to another question, so I figure we might as well have a standard answer on the site.
A classic proof of this fact is due Schreier; he used free products with amalgamation. He then also deduced the nontrivial fact that epimorphisms are surjective in the category of finite groups.
Carl Linderholm (of Mathematics Made Difficult fame) published a 1 page elementary proof in "A Group Epimorphism is Surjective", in the American Mathematical Monthly 77, pp. 176-177. I gave the proof on sci.math
back in 2000. This is this proof with slightly different notation.
Let $f\colon H\to K$ be an epimorphism. We seek to find a group $S$ and two morphisms $g,h\colon K\to S$ such that $gf=hf$, and then use the conclusion that $g=h$ to conclude that $f(H)=K$.
Let $X=K/f(H)$ be the set of right cosets of $f(H)$ in $K$. Let $\infty$ be something which is not an element of $X$, and let $Y=X\cup\{\infty\}$. Let $S$ be the group of permutations on $Y$.
The right action of $K$ on $X$ induces an embedding of $K$ into $S$ as permutations that fix $\infty$; call this map $g$. Now let $\sigma\in S$ be the permutation that exchanges the coset $f(H)$ with $\infty$ and fixes everything else. let $h\colon K\to S$ be the homomorphism we get by composing $g$ with conjugation by $\sigma$ in $K$.
Now, consider $h$ and $g$. If $x\in H$, then $f(x)$ fixes the coset $f(H)$ and fixes $\infty$. Thusm the support of $g(f(x))$ and $\sigma$ are disjoint hence they commute: $h(f(x))=\sigma^{-1}\circ g(f(x))\circ \sigma=g(f(x))$. That is, $h\circ f = g\circ f$.
Since $f$ is an epimorphism, we conclude that $h=g$.
But that means that for all $k$, $h(k)=g(k)$. In particular, $g(k)$ must commute with $\sigma$ for all $k$. This requires
that $g(k)$ leave $f(H)$ fixed. But that requires $k\in f(H)$. That is, we must have $f(H)=K$, so $f$ is surjective, as claimed.
Note, along the way, that when $K$ is finite the group $S$ is also finite. So this also proves that epimorphisms are surjective in the category of all finite groups, something which is not immediately obvious from Schreier’s Theorem. However, Schreier’s Theorem is stronger than the assertion that epimorphisms are surjective: it proves that every subgroup is an equalizer subgroup; i.e., if $H\leq G$, then there exist a group $K$ and morphisms $f,g\colon G\to K$ such that the equalizer of $f$ and $g$ is exactly $H$: $\mathrm{Eq}(f,g)=\{x\in G\mid f(x)=g(x)\}=H$.