Magnetic monopoles, duality and cosmological phase transitions