First part of support for optional types

Added optional val, and encode and decode.

The decode is a bit nasty since for anything that isn't a string we want to decode "" as None. However, for string we decode it as Some("").
why `Option` here? Are we expecting a possible `null` value? I wasn't aware we received any?