changed python script to detect file encodings