Find a stable transfer function $G(z)$ such that $|G(z)| = |H(z)|$ Consider the following causal IIR transfer function:
  $$ H(z) = \frac{2z^3 - 4z^2 + 9}{(z-3)(z^2+z+0.5)} $$
  
  Is $H(z)$ a stable function? If it is not stable, find a stable transfer function $G(z)$ such that $|G(z)| = |H(z)|$.


Now obviously the transfer function is not stable due to the pole at $z = 3$.
And I would have just thought that the solution was to flip this pole inside the unit circle, so $z = 1/3$.

And so  $G(z)$ should be $  = \frac{2z^3 - 4z^2 + 9}{(z-1/3)(z^2+z+0.5)}$ right?

The solutions however go $  G(z)= \frac{2z^3 - 4z^2 + 9}{(1-3z)(z^2+z+0.5)}$, which seems fine, except for the next step, where they go $G(z) = H(z)A(z)$ where $A(z) = \frac{1-3z}{z-3}$

That part makes no sense to me, since $$H(z)A(z) =  \frac{(1-3z)(2z^3 - 4z^2 + 9)}{(z-3)^2(z^2+z+0.5)} \neq G(z)$$


  Can someone please explain a) what am I doing wrong; and b) why we introduce $A(z)$?
Your idea of replacing the pole $p$ outside the unit circle (i.e., $|p|&gt;1$) with a pole $1/p^*$ inside the unit circle is correct. However, as mentioned in this answer, you need to be careful with the scaling. In order to obtain the correct scaling, a factor $(z-p)$ in the denominator must be replaced by a factor $\pm |p|(z-1/p^*)$. In that way the magnitude of the transfer function will be unchanged on the unit circle, i.e., for $|z|=1$. This should also be added to the problem formulation:


  ... such that $|G(z)|=|H(z)|$ for $|z|=1$.


Clearly, the new stable transfer function $G(z)$ can be written as the original transfer function $H(z)$ cascaded with an allpass filter $A(z)$, since $|A(z)|=1$ for $|z|=1$:

$$G(z)=H(z)A(z)\quad\Longrightarrow\quad |G(z)|=|H(z)|,\quad |z|=1\tag{1}$$

For the given problem, the transfer function $A(z)$ is given by

$$A(z)=\frac{z-3}{1-3z}\tag{2}$$