Encoding related py3 fixes