Fix for all metaclasses to be py2/3 compatible

Metaclasses are handled as per the tooling of the 'six' library, but without
introducing a dependency on six -- the needed helper is included directly in
the source tree, under the license and copyright of the six project.