fix stdout ordering with python3