Fixing a potential problem with encoding in Python3