Fix Python 3 encoding errors