The XMM-Newton Serendipitous Survey. VI. The X-ray Luminosity Function