In [2]:
%pylab inline
from astropy.io import fits
test = fits.open("subaru_IB427_042_sci_10.fits")
test[0].data[np.where(np.isnan(test[0].data))[0],np.where(np.isnan(test[0].data))[1]] = 65535.
test.writeto("IB_pixreplace_42.fits")