Should fix #2794 and a related issue (in that the replaced code had this bug as well) with writing non-contiguous arrays to non-file objects.
Fix mistake in chunksize calculation
Merge pull request #2794 from embray/fits/gzip-bugs

fits.writeto writes a corrupt file if the file name ends .gz