Precomposing a rational function $f$ with a birational isomorphism $g$ to make $f\circ g$ regular? I think I have a gap in my understanding,

Suppose $Y$ and $Z$ are quasi-projective varieties, and that $Y$ is irreducible. Suppose we have a rational map $f\colon Y\to Z$. Then we know there exists a regular, birational isomorphism $g\colon X\to Y$, for $X$ also quasi-projective, making $f\circ g\colon X\to Z$ a regular map...

I don't follow the existence of such $g$? Is there a nice explanation or proof of why such $g$ should exist? Thanks, I'd appreciate understanding why.
 A: Zhen Lin gave a very elegant answer. However, sometimes taking an open set isn't really what you want to do --- for example if $Y$ is projective, and you would like $X$ to be projective too.
There is a different way of finding such a $g$ that is surjective, and hence has the good properties mentioned, as follows.
Let $\Gamma_f$ be the graph of $f$ inside $Y \times Z$. So $\Gamma_f$ is isomorphic (via the first projection) to the locus where $f$ is defined, and the diagram
$$\require{AMScd}
\begin{CD}
\Gamma_f @= \Gamma_f \\
@V{\mathrm{pr}_1}VV  @VV{\mathrm{pr}_2}V \\
Y @>>{f}> Z
\end{CD}$$
commutes.
Now simply define $X=\overline{\Gamma_f}$ and $g = \mathrm{pr}_1$. Then $\Gamma_f$ is a dense open subset in $X$, and $g$ is an isomorphism on this subset, hence $g$ is birational. Moreover $f \circ g$ on $\Gamma_f$ is equal on $\Gamma_f$ to $\mathrm{pr}_2$, hence extends to a regular map on all of $X$ (since $\mathrm{pr}_2$ is defined everywhere on $X$). 
A: A rational map $Y \to Z$ is regular on some non-empty open $X \subseteq Y$, and since $Y$ is irreducible, $X$ is dense in $Y$. Let $g : X \to Y$ be the inclusion. Then $g$ is a birational isomorphism, and $f \circ g :  X \to Z$ is indeed regular. 
