file averaging made to work in python3