Added file encoding support with options and autodetection

Closes #95