We will show that in fact, any epimorphism f:C→B in a topos is effective, i.e. f is the coequalizer of the two projections C×BC→C. Thus, suppose we have a morphism g:C→X such that g∘π1=g∘π2. Then set I to be the image of (f,g):C→B×X. We claim that the first projection I→B is an isomorphism; then the required morphism B→X will be the composition of the inverse of I→B with the second projection I→X (and the uniqueness of the map B→X will be an immediate consequence of f being an epimorphism).
To see this, first note that the projection π¯1:I→B is certainly an epimorphism, since π1∘(f,g)=f is an epimorphism. Therefore, we reduce to showing that the projection I→B is a monomorphism. To see this, suppose we have two morphisms i,j:U→I such that π¯1∘i=π¯1∘j. Then there exists an epimorphism V→U and two morphisms i¯,j¯:V→C making appropriate commutative diagrams with i,j respectively. But then the fact that π¯1∘i=π¯1∘j implies that (i¯,j¯) induces a morphism V→C×BC. Therefore, the assumption g∘π1=g∘π2 implies that g∘i¯=g∘j¯; and from V→U being an epimorphism, we get that π¯2∘i=π¯2∘j also. From here, we can conclude that in fact i=j.
In case there is any difficulty in filling in the details of this
argument, let me just comment that this is a categorization of this
completely elementary argument for the case of Set: first, with the given setup, the assumption g∘π1=g∘π2 amounts to the requirement that whenever c1,c2:C are such that f(c1)=f(c2), then g(c1)=g(c2). Now, I={(b,x):B×X∣∃c:C,f(c)=b∧g(c)=x}. It is immediate from f being surjective that every b:B occurs as a first coordinate of an element of I. On the other hand, if (b,x1),(b,x2)∈I, then there exist c1,c2:C such that f(c1)=f(c2)=b, g(c1)=x1, and g(c2)=x2. But then the assumption g∘π1=g∘π2 gives x1=x2. Thus, we have shown that I is the graph of some function B→X.
(Also, let me observe that the dependencies of the topos case
argument are: that a topos is balanced, i.e. every morphism which is a
monomorphism and an epimorphism is an isomorphism; the existence of
images, i.e. epi-mono factorizations; and that in a topos, epimorphisms
are stable under pullbacks.)