fix key encoding regression

v3.1.0 introduced a regression where maps and keyword lists containing the key
`nil` were not properly encoded