Fixes spacetelescope/PyFITS#71

This is a fix I merged in from PyFITS (see spacetelescope/PyFITS#71).  I've already tested this on the PyFITS end, so if the tests pass here it should be merged in.  It's a bug that can lead to writing corrupt data which is always bad.
Didn't mean to include this in this PR. But it's harmless so I'll just go ahead and leave it for now.