Fermi averaging and Pauli blocking corrections to the pion optical potential in nuclear matter