The VIMOS Public Extragalactic Redshift Survey (VIPERS). A precise measurement of the galaxy stellar mass function and the abundance of massive galaxies at redshifts 0.5 < z < 1.3