Bring over some of the platform-specific workarounds from astropy.io.fits