Explicitly close read and write of Popen process (latex)

This suppresses the final unclosed buffer/file warning in the test suite on python3.4. 

When reading and writing from directly from stdout and stdin of the popen process they
should be explicitly closed afterwards.