Use tempfiles instead of PIPE

Seems like this should fix the >64k result problem.