I'll add another proof here, the continuous analog of Fang-Yi Yu's proof:
Assume $Y_1$ and $Y_2$ are continuous. For real numbers $y_1$ and $y_2$, we can define:
$S_{y_1} = \{{x_1: g(x_1)\le y_1} \}$ and
$S_{y_2} = \{{x_2: h(x_2)\le y_2} \}$.
We can then write the joint cumulative distribution function of $Y_1$ and $Y_2$ as:
\begin{eqnarray*}
F_{Y_{1},Y_{2}}(y_{1},y_{2}) & = & P(Y_{1}\le y_{1},Y_{2}\le y_{2})\\
& = & P(X_{1}\in S_{y_{1}},X_{2}\in S_{y_{2}})\\
& = & P(X_{1}\in S_{y_{1}})P(X_{2}\in S_{y_{2}})
\end{eqnarray*}
Then the joint probability density function of $Y_{1}$ and $Y_{2}$
is given by:
\begin{eqnarray*}
f_{Y_{1},Y_{2}}(y_{1},y_{2}) & = & \frac{\partial^{2}}{\partial y_{1}\partial y_{2}}F_{Y_{1},Y_{2}}(y_{1},y_{2})\\
& = & \frac{d}{dy_{1}}P(X_{1}\in S_{y_{1}})\frac{d}{dy_{2}}P(X_{2}\in S_{y_{2}})
\end{eqnarray*}
Since the first factor is a function only of $y_{1}$ and the second
is a function only of $y_{2}$, then we know $Y_{1}$ and $Y_{2}$
are independent (recall that random variables $U$ and $V$ are independent
random variables if and only if there exists functions $g_{U}(u)$
and $h_{V}(v)$ such that for every real $u$ and $v$, $f_{U,V}(u,v)=g_{U}(u)h_{V}(v)$).