Handle params key encoding error.

Explicitly raise error in case of encoding error. Fixes(?) #610.