Fix LookupError for unknown encodings.

Sets the preferred encoding to UTF-8 if python is unable to find a codec
for the value returned by locale.getpreferedencodings() function.