Loop expansion around the Bethe-Peierls approximation for lattice models