Fix sporadic truncation of output files
Fixed a bug where the resulting data would be blank.

Changed the exit event to be 'close' since 'exit' can be sent even though the stdio streams are still open. The alternative is to use the 'close' event which is emitted when all stdio streams are closed and the program has exited.
Emit errors with data
add setEncoding UTF8

add ".stdout setEncoding('utf8')"
for ISO-8859-1 special characters not translated correctly