added codec, chunk encoding when write on resource
added CodecError
dive into 3.x compat: bytes workaround