python 3 compatibility (and 2 back compatibility)