Change to support Python 2.6.

Python 2.6 doesn't support check_output so we implement it here.