WIP: refactor RDF serialization

still the old PR - do not merge

Test notebook:

http://nbviewer.ipython.org/urls/dl.dropbox.com/s/t70r4dmhtky734b/RDFtestsuite.ipynb?create=1