BytesIO TypeError

This fixes #3.

Thanks to @AndrewPashkin for the original test, and @zsiciarz for pointing me in the correct direction for fixing this.