Since $(f + ig)(f-ig) = f^2 + g^2 = 1$, the function $f+ig$ has no zeros. It follows that $f+ig$ has a holomorphic logarithm. That is, there exists a holomorphic function $h$ such that $f+ig = e^{ih}$. This implies $f-ig = (f+ig)^{-1} = e^{-ih}$. It follows
$$f = \frac{1}{2}(f+ig) + \frac{1}{2}(f-ig) = \frac{1}{2}(e^{ih} + e^{-ih}) = \cos(h).$$
Similarly,
$$g = \frac{1}{2i}(f+ig) - \frac{1}{2i}(f-ig) = \frac{1}{2i}(e^{ih} - e^{-ih}) = \sin(h).$$
EDIT: As there seems to be some confusion about holomorphic logarithms, here is a proof that any holomorphic function $F: U \to \mathbb{C}$ with simply connected $U$ and $F(z) \neq 0$ for all $z \in U$ has a holomorphic logarithm. Let $G$ be the antiderivative of $\frac{F'}{F}$. $G$ exists because $F$ has no zeros and $U$ is simply connected. Now observe
$$(e^{-G}F)' = -e^{-G}G'F + e^{-G}F' = e^{-G}(F'-G'F) = 0.$$
Thus $e^{-G}F$ is constant. It follows $F = Ce^{G}$ for some constant $C$. Let $C = e^{\tilde{C}}$. It follows that $G + \tilde{C}$ is a holomorphic logarithm of $F$.
Now for the above choose $F = f+ig$ and $h = -i(G+\tilde{C})$.