Use subprocess.check_output to avoid deadlock.

The program deadlocked if the stdout buffer got full due to the
use of pipes. Using check_output without pipes fixes this.