Added isinstance(metadata, str) check before running encode on metadata.
Closes #134
Merge pull request #135 from petteraas/str_check_before_encode

Added isinstance(metadata, str) check before running encode on metadata. Closes #134