Avoid errors with logging in some systems 

In some systems the output of locale.getpreferredencoding() can be an empty string. Feeding the empty string to "decode" will raise an error. This patch avoids the input of an empty string to "decode" in these cases.