Let $R$ be a PID and $A,B$ be two $m\times n$ matrices over $R$ with $m\leq n$. I want to show that if $A$ and $B$ have the same image, they only differ by multiplication by an invertible matrix from the right.
Expressing the column vectors of A,B by linear combinations of the column vectors of B,A yields square matrices $X,Y$ with $AX=B,\ BY=A$ and thus $AXY=A,\ BYX=B.$
Using the fact that $R$ is a PID, I can apply the elementary divisor theorem and assume $A$ to be "diagonal", meaning of the form $A=\left(\frac{\textrm{diag}(e_1, \dotsc, e_m)}{0} \right)$ for some $e_i\in R$.