Josh Allen threw three touchdown passes, James Cook rushed for 108 yards and a score, and the Buffalo Bills took down the Miami Dolphins 31-21 Thursday night in Orchard Park, N.Y.