For scheme-theoretic images to be well-behaved, you need the morphisms to be quasi-compact.
Some sources will also require quasi-sep., but that is not necessary; quasi-compact is enough for the the kernel of $\mathcal O_Y \to f_*\mathcal O_X$ to be a quasi-coherent ideal sheaf, which then cuts out the scheme-theoretic image of $f: X \to Y$.
Once you have this sheaf-theoretic description, checking compatibility with flat base-change, and so in particular with Zariski localization, is straightforward.
Details are in the stacks project.
One can then check things like compatibility with compositions (as in your question) just by computing successive kernels of the pull-back maps; i.e. in terms of the ideal sheaves described above.
In the non-quasi-compact case, for morphisms of non-reduced schemes (so that the
scheme-theoretic images aren't determined by topology alone) things can be a mess, and you can presumably find counterexamples to statements that you might naively guess were true. The stacks project gives some such counterexamples, and once you see how to make them, you can probably create more.
One more thing: even in the quasi-compact case, scheme-theoretic images don't typically commute with non-flat base-change.
First of all, if $X \to Y$ is not surjective, but is scheme-theoretically dominant (i.e. has $Y$ as its scheme-theoretic image) and you take $y \in Y$ to not lie
in the image, then the scheme-theoretic image of the base-change to $y \in Y$ is empty,
while the base-change of the scheme-theoretic image is $y$ itself.
More substantively, even if $X \to Y$ is scheme-theoretically surjective
(not just scheme-theoretically dominant), i.e. is surjective and has $Y$ as its
scheme-theoretic image, it's pretty easy to find examples which don't commute
with base-change to $y \in Y$.
This isn't a pathology, but is reasonable when you think about the construction in terms of kernels of maps of ring (as above), since formation of kernels doesn't typically commute with non-flat base-change. It's not to hard to find counterexamples even in very simple settings; my memory is that Eisenbud and Harris give some, and that I found them once just by googling something like "scheme theoretic image + base-change". Once you think in terms of kernels, you can probably make some counterexamples by yourself, in any case.