Convert key to string before encoding in `key`.

Closes #24.