Fix stdout issue on Python3