catch Encoding::UndefinedConversionError for compatibility with JRuby 1.9 mode