Try to be clever on what type of response we received

Previously we were trying to encode/decode every response into JSON.
This caused problem with response that can't be JSON encoded, such as
binary data. It was also inefficient.

Now we return the raw response we received. One exception is for
object. Both array and object will be encoded as array in the
response. If the response is an array, we check if it's associative,
if so we cast it to an object before returning it.