Computation of the relation between the bare lattice coupling and the MS coupling in SU(N) gauge theories to two loops