Encoding/decoding of files

When using the pipe, `ExternalTool.subprocess` encodes/decodes unicode properly, but when using files it doesn't. It is not encoding the unicode `data` when it writes to the input file, and also is writing inconsistent types to `out`. This fixes this issue.
Merge pull request #297 from Kronuz/patch-1

Encoding/decoding of files