encode lists as json in Handler.write

in write/finish: treat `list` object as `json`. encode the list and set headers.