fix encoding errors for python3