Let $f\colon X \rightarrow Y$, $g\colon Y' \rightarrow Y$, be two morphisms of schemes. Let $X' = X\times_Y Y'$, and let $f'\colon X' \rightarrow Y'$ be the projection. We are interested in the relation between the scheme theoretic image of $f'$ and that of $f$ (in the sense of Hartshorne, exercise II, 3.11). Namely, when does $f'(X') = g^{-1}(f(X))$ hold?
Note that the equality holds for set theoretic images (see this question), so I am asking whether (or under what conditions) the scheme structure is also preserved.