Rewrite checks to use communicate.

This ensures that file handles are cloesed
Silence some more cloesed file warnings
Ensure that file is closed in texmanager
Remove leftover debug
Correct stdout in dvipng_hack
Change checks to more closly match the original
Add breaks to match original
Merge pull request #3235 from jenshnielsen/more_warnings

Silence some more warnings