Added the ability to serialise themes

Added a simple test. Needs more work to make the output correct. There are clearly a few things wrong at the minute.