use check_output instead to avoid potential command injection
update string handling to unicode for python3