Improve Python 3 Compatibility
merge python3 compatibility