Fix use_nil in encode, use_undefined flag.

There was a segmentation fault error on encode whith use_nil flag.

In addition to use_nil I've added use_undefined.
When is on :undefined also encodes to null.