Two-loop divergences of massive scattering amplitudes in non-abelian gauge theories