WIP: refactor RDF serialization


Test notebook:

http://nbviewer.ipython.org/urls/dl.dropbox.com/s/t70r4dmhtky734b/RDFtestsuite.ipynb?create=1