Replace __metaclass__

The __metaclass__ syntax is not compatible with Python 3, this patch will
replace it with the add_metaclass decorator provided by the six library
which make it easier to add metaclasses that works on both Python 2 and 3.

The patch also grouped some imports as per PEP8.

Change-Id: If4fcee8ec4bb5e7d6971ea5a4143fba6500a09e9
Partial-Bug: #1249886
Merge "Replace __metaclass__"