python: optimize to_x() & to_x_32() for python3