I felt this was trivial, but I wanted to make sure. The proofs I've read which show that the image of a group homomorphism is a subgroup of its codomain only prove that closure, identity, and inverse are preserved in the image. I wrote this fast proof to see if this is a correct way to show that associativity is also always preserved:
Let $(G , \times)$ and $(H, \dot \times)$ be groups and let $G \xrightarrow{\quad \varphi \quad} H$ be a homomorphism. If $a, b , c\in \mathrm{im}\varphi$ then there exist elements $a', b', c' \in G$ such that $\varphi(a') = a$ and $\varphi(b') =b$ and $\varphi(c') = c$. Then since group homomorphisms must preserve the group operation:
$(a \times b) = (\varphi(a') \dot \times \varphi(b')) = \varphi(a' \times b')$.
Similarly,
$(b \times c) = (\varphi(b') \dot \times \varphi(c')) = \varphi(b' \times c')$.
Now, we know also that
$ (a' \times b') \times c' = a' \times (b' \times c')$
which implies:
$\varphi((a' \times b') \times c') = \varphi(a' \times b') \dot \times \varphi(c') = (\varphi(a') \dot \times \varphi(b')) \dot \times \varphi(c') = (a \dot \times b) \dot \times c$
Similarly,
$\varphi(a' \times (b' \times c')) = \varphi(a') \dot \times \varphi(b' \times c') = \varphi(a') \dot \times (\varphi(b') \dot \times \varphi(c')) = a \dot \times (b \dot \times c)$
A homomorphism is a function, thus no element in the domain can map to multiple points in the codomain.
Since our homomorphism is a function we know then that $(a \dot \times b) \dot \times c = a \dot \times (b \dot \times c)$
I apologize if this was not the most concise way to prove things, I did not see this proved online after doing a bit of searching, and wanted to check quickly. Thank you for looking.