Fix UnicodeDecode error and make models Python 3 compatible.