Python 3 uses readinto() instead of read() in places. And
taking a slice of the buffer passed to readinto() will produce
a memoryview. _writedata() then gets confused when testing for
b'\n' in data because memoryview is an iterable over ints
instead of 1 character bytes.
We work around by casting a memoryview to bytes.