Add Ruby 1.8 support

URI.encode_www_form was introduced in 1.9. This backports it for 1.8 support.