Ported to python 3, hopefully fixed those damn encoding failures