Fix all bytes-str encoding related bugs on Py3