Fix UnicodeEncodeError in DIDL-code.
Move common code into central module - and clean it up.