Moved code that will be in Astropy 1.0 into wcs_utils.py