Fix autowidth in combination with sanitizing

By only sanitizing just before serialisation.
Merge pull request #301 from jurriaan/autowidthfix

Fix autowidth in combination with sanitizing