new conditional file encoding for python 3