Here's a proof in constructive set theory (probably just a rephrasing of the topos theoretic proof but you might find it useful).

Let $h : A \twoheadrightarrow B$ be an epimorphism. Define
$$
C := \{\{0\}\} \cup \bigcup_{b \in B}\{\{x \in \{0\} \;|\; \exists a \in A\; h(a)=b\}\}
$$
(If the powerset axiom is available, one can alternatively use $C := \mathcal{P}(\{0\})$)

Define functions $f, g : B \rightarrow C$ as follows.
$$
f(b) := \{ x \in \{0\} \;|\; \exists a \in A\;h(a) = b \} \\
g(b) := \{0\}
$$

We clearly have $f \circ h = g \circ h$, so since $h$ is an epimorphism, we get $f = g$. Now for any $b \in B$, we have that $f(b) = g(b)$. Therefore the set $\{x \in \{0\} \;|\; \exists a \in A \; h(a) = b \}$ is inhabited, and so there exists $a$ in $A$ such that $h(a) = b$.