fixed exception handling for subprocess.check_output calls