Phase stability and electronic behavior of MgS, MgSe and MgTe compounds