Let $f:(X,\mathcal{O}_X)\rightarrow (Y,\mathcal{O}_Y)$ be a morphism of ringed spaces. This is the data of a map $f:X\rightarrow Y$ between the topological spaces and either a morphism of sheaves $$f^{\flat}:\mathcal{O}_Y\rightarrow f_*\mathcal{O}_{X} \ \ \text{ or } \ \ f^{\sharp}:f^{-1}\mathcal{O}_Y\rightarrow \mathcal{O}_X$$
Giving one morphism or the other is the same thanks to the adjuntion $$\text{Hom}_X(f^{-1}\mathcal{O}_Y,\mathcal{O}_X)\cong \text{Hom}_Y(\mathcal{O}_Y,f_*\mathcal{O}_X)$$
Is it true that under this bijection, monomorphisms/epimorphisms correspond to monomorphisms/epimorphisms?
I wonder this because we now that for every $x\in X$ there is an induced morphism between stalks $$\mathcal{O}_{Y,f(x)}\rightarrow\mathcal{O}_{X,x}$$ This map coincide with $f^{\sharp}_x:(f^{-1}\mathcal{O}_{X})_x=\mathcal{O}_{Y,f(x)}\rightarrow \mathcal{O}_{X,x}$ but is not in general equal to $f^{\flat}_{f(x)}:\mathcal{O}_{Y,f(x)}\rightarrow (f_*\mathcal{O}_{X})_{f(x)}$ because in general we don't have $(f_*\mathcal{O}_{X})_{f(x)}=\mathcal{O}_{X,x}$.
Now if we want to show that $f$ is an epimorphism, this (sometimes by definition) means that $f^{\flat}$ is an epimorphism. In the other hand if we prove that $f$ is an epimorphism on stalks we are proving that $f^{\sharp}$ is an epimorphism. So if I want to show that $f$ is an epimorphism iff is an epimorphism on stalks I need the above result (same with monomorphism).
Also, I have another minor question related with this. It is true that if the canonical map $(f_*\mathcal{O}_{X})_{f(x)}\rightarrow\mathcal{O}_{X,x}$ is an isomorphism then the above maps between stalks are equal?
Thanks in advance.