Replaced check_output with Popen + communicate().

check_output() wasn't introduced until Python 2.7.