Support String#encode if available

Ruby 1.9 deprecates 'iconv' in favour of String#encode.