Fix bug in python3 due to improper string handling