Re-organize handle_encoding to assume bytes for input and do simple decoding of headers as ASCII in order to ascertain the encoding.
Replace NONE values after decoding the headers
Use BytesIO instead of cStringIO
Fix test on Python 3
Open files as binary
Fix more test failures due to testing against str type
Fix two more failing tests