Rewrite TempFileReader to avoid mktemp() and CLI encoding issues

* Ignore broken pipe when closing buffered pipe. Python 2’s os.popen() seems
  to ignore this already.
Rewrite JPEG parser to avoid mktemp() and CLI encoding issues