Typo
Move check_output() to shared function

Remove two duplicated check_output() functions.

This also fixes a Python 2.6 error that when the subprocess exited with
non-zero check_output() was calling CalledProcessError with an argument
that doesn't exist in 2.6.