Structure and electronic properties of transition-metal/Mg bimetallic clusters at realistic temperatures and oxygen partial pressures