Fix errors, have to deal with UTF-8 detection not working in PY3