The actual question:
$f(z)$ is holomorphic in some neighbourhood of $0$, $f(0) = 0$, $f'(0) =/= 0$. Suppose $f(z)$ maps the real axis to the imaginary axis and suppose it maps the imaginary axis to a line $l$. Prove that $l$ is the real axis using the Cauchy Riemann equations.
Attempt:
It suffices to show that $f$ maps imaginary values to real values in a neighbourhood of $0$ since we know that $l$ is a line. To do this, we can show that $v_y(z) = 0$ for all imaginary values in a nbhd of $0$ since we know that $v(0) = 0$ and $v_y(z) = 0$ for imaginary values implies that $v = 0$ everywhere on the imaginary axis.
Write $f = u + iv$. Then $f(x)$ is imaginary for real $x$, so $u(t) = 0$ for all real $t$. This implies $u_x(t) = 0$ as $u$ is constant with respect to moving along the real axis (always $0$). By Cauchy Riemann, in a neighbourhood of $0$, we have $u_x = v_y$, so $v_y(t) = 0$ too. How do I now get $v_y(z)$?
The Cauchy-Riemann equation gives that (locally invertible) holomorphic maps are conformal maps. If the real axis is mapped into the imaginary axis and the imaginary axis is mapped into a line $\ell$, the angle between the real and imaginary axis ($90^\circ$) has to be the same as the angle between the imaginary axis and $\ell$.
I am assuming $f(0)=0$ and $f'(0)\color{red}{\neq} 0$. Otherwise $f(z)=iz^2$ provides a counter-example.
Alternative way: let $\sum_{n\geq 1}i^{-n}a_n z^n$ be the Maclaurin series of $f(z)$, convergent over some neighbourhood $D$ of the origin. Since $f$ maps $i\mathbb{R}\cap D$ into $\mathbb{R}$, all the coefficients $a_n$ are real (and $a_1\neq 0$). There is some $\omega\in S^1$ (the unit vector giving the direction of $\ell$) such that $\mathbb{R}\cap D$ is mapped into $\omega\mathbb{R}$, so $$ g(z) = \omega^{-1} f(z) $$ maps $\mathbb{R}\cap D$ into $\mathbb{R}$. By considering the Maclaurin series of $g(z)$ it follows that $\omega^{-1}i^{-n} a_n$ is real for any $n\geq 1$, so $\omega=\pm i$ and $a_{2m}=0$ for any $m\geq 1$.
I have exploited the following lemma: if $h(z)=\sum_{n\geq 0}a_n z^n$ is holomorphic in a neighbourhood $U$ of the origin and such that $h$ maps $\mathbb{R}\cap U$ to $\mathbb{R}$, then $a_n\in\mathbb{R}$ for any $n\geq 0$. Proof: $a_n$ is $\frac{1}{n!}$ times the $n$-th derivative of $h$ at the origin, which can be computed as the real limit $$ \lim_{t\to 0^+}\frac{1}{t^n}\sum_{k=0}^{n}\binom{n}{k}(-1)^{n-k}\underbrace{h(kt)}_{\in\mathbb{R}}. $$ In simpler terms, the $n$-th complex derivative of $h$ at the origin has to agree with the $n$-th derivative of $h$, intended as a real function defined on $\mathbb{R}\cap U$.