Honor toJSON/toXML() for XML support

/to @ritch @bajtos 

The PR allows customization of JSON to XML conversion using toJSON()/toXML(). It also adds some test cases for XML media types.
~~Did you see this test fail? It seems to me that `a.toJSON` returns the same object as itself, thus even if `toJSON` was not called, the result would be the same and the test would pass.~~

Oh! You are swapping `x` and `y` property values. That's very difficult to spot. Can you please apply a different transformation, one that does not require the reader to carefully examine all individual letters?

E.g.

```js
return {
  one: a.x,
  two: a.y
}

// or even
return {
  foo: a.x,
  bar: a.y
}
```

If you don't like that, then at least add a comment explaining that `toJSON` is swapping property values.