Magnetic device cooling