Added support for an optional serializer.

Hi Fabian,

I added the option of passing a serializer.
I also added some tests to make sure it works.

Let me know if you are interested in merging it and releasing a new version on pypi.

Thanks
Michael
I'm not sure to see what you mean but yes you can definitely add more tests.