Add file-encoding detection

use encoding detection as implemented in
http://hg.python.org/cpython/file/72b1715e18c1/Tools/scripts/findnocoding.py
to figure out what encoding the simplates are using.