Fixed issues with encoding in setup and download via tempfile, issue #142