fix handling of special characters when using Python 3