Some superfluous whitespace fixes
Adds a test and kind of hacky fix for #1244. Basically we try to decode the byte string using locale.getpreferredencoding(), but if that returns an invalid encoding we try decoding with utf-8. If that fails (do to undecodable bytes) we just fall back on latin-1.  Therefore we always output *something* though there's no 100% guarantee it won't be gibberish if the system's default encoding is incorrect.
Merge pull request #1244 from iguananaut/issue-1244

Problems with logging in some systems