Proof (image on generating set determines homomorphism)
Let $\phi$ and $\psi$ be homomorphisms $G\to H$ that agree on $X$. Consider the set $$ G' = \sb{g \in G}{\phi(g) = \psi(g)}. $$ For all $g_1, g_2 \in G'$, $$ \phi(g_1g_2\inv) = \phi(g_1) \phi(g_2)\inv = \psi(g_1) \psi(g_2)\inv = \psi(g_1) \psi(g_2) $$ So by the subgroup criterion, $G'\leq G$.
Note that $X \subseteq G'$. Hence since $G = \gen X$, $G' = G$.