fix Popen encoding issue by replacing stdin pipe with a tempfile