The main question
Let $ A $ and $ B $ be two algebras over the real numbers, and let $ J $ be an ideal of $ B $. Let $ f\colon A\to B $ be a homomorphism of $ \mathbb R $-algebras, and suppose $ f^{-1}(J)\subset \ker q \circ f $, where $ q $ is the canonical projection $ q\colon B\twoheadrightarrow B/J $.
Then there exists a unique (injective) homomorphism $ \tilde f $ making the diagram $$ \require{AMScd} \begin{CD} A @>p>> A/f^{-1}(J)\\ @VfVV @VV{\tilde f}V\\ B @>q>> B/J \end{CD} $$ commute. Is it the case that $ \tilde f $ is an isomorphism?
Some unnecessary context
At the moment I'm reading Wedhorn's Manifolds, Sheaves, and Cohomology, and at some point this question came out.
More precisely, it is claimed in the book that every morphism of ringed spaces of the form $ (\mathbb R^n,\mathscr C_{\mathbb R^n}^\infty) $, where $ \mathscr C_{\mathbb R^n}^\infty $ is the sheaf of smoth functions on the euclidean space $ \mathbb R^n $, is automatically a homomorphism of locally ringed spaces.
Indeed, let $ (f,f^\flat)\colon (\mathbb R^n,\mathscr C_{\mathbb R^n}^\infty)\to (\mathbb R^m,C_{\mathbb R^m}^\infty) $ be a morphism of ringed spaces and let $ x\in \mathbb R^n $. Then $ (f,f^\flat) $ induces a homomorphism of $ \mathbb R $-algebras $$ \psi\colon \mathscr C_{\mathbb R^m,f(x)}^\infty/f_x^{-1}(\mathfrak m_x)\to \mathscr C_{\mathbb R^n,x}^\infty/\mathfrak m_{x} $$ where $ f_x\colon \mathscr C_{\mathbb R^m,f(x)}^\infty\to \mathscr C_{\mathbb R^n,x}^\infty $ is the canonical map between the stalks at $ x $ and $ \mathfrak m_x $ is the maximal ideal of $ \mathscr C_{\mathbb R^n,x}^\infty $. The author claims then that $ \psi $ is surjective, and thus an isomorphism. This shows that (the quotient algebra $ \mathscr C_{\mathbb R^m,f(x)}/f^{-1}(\mathfrak m_x) $ is isomorphic to the field $ \mathscr C_{\mathbb R^n,x}/\mathfrak m_x\cong \mathbb R $ and thus) $ f^{-1}(\mathfrak m_x) $ is a maximal ideal. I'm overwhelmed by all this beautiful symbols and I'm not able to see why this should be the case.
We don't need to suppose that $f^{-1}(J)\subseteq \ker(q\circ f)$; this is automatically satisfied.
The map $\tilde{f}$ will be injective (check this!). But $\tilde{f}$ may not be surjective. If you assume that $f$ is surjective, then $\tilde{f}$ is surjective, so $\tilde{f}$ is an isomorphism.
E.g. take $f:\mathbb R\to \mathbb R[x]$ to be the inclusion map (which is not surjective) and $J=0$; then $\tilde{f}=f$ is not an isomorphism.