Fixed encoding bug with in PY3