A Potential Enstrophy and Energy Conserving Scheme for the Shallow Water Equations