account for python 2/3 differences, and byte order marks