Refactor convert() function to serialize().

Take advantage of PyYAML in python3.

Change-Id: Id208c825857d0a12862923448dd31147806bdb2b