Try to handle UTF-8 shell output better

Rescue "invalid byte sequence in US-ASCII" exception when logging, and
try to convert the string's encoding to UTF-8.