Applying RJacksonm1's fix for using bz2 and file like objects