Revert encode of buffer on write (fix for python 3 compat a better way).