Understanding the link between massive (≳30M⊙) stellar black holes (BHs) and their progenitor stars is a crucial step to interpret observations of gravitational-wave events. In this paper, we discuss the final fate of very massive stars (VMSs), with zero-age main sequence (ZAMS) mass > 150 M⊙, accounting for pulsational pair-instability supernovae (PPISNe) and for pair-instability supernovae (PISNe).We describe an updated version of our population synthesis code SEVN, in which we added stellar evolution tracks for VMSs with ZAMS mass up to 350M⊙ and we included analytical prescriptions for PPISNe and PISNe. We use the new version of SEVN to study the BH mass spectrum at different metallicity Z, ranging from Z = 2.0 × 10-4 to 2.0 × 10-2. The main effect of PPISNe and PISNe is to favour the formation of BHs in the mass range of the first gravitational-wave event (GW150914), while they prevent the formation of remnants with mass 60-120M⊙. In particular, we find that PPISNe significantly enhance mass-loss of metal-poor (Z ≤ 2.0 × 10-3) stars with ZAMS mass 60 = MZAMS/M⊙ ≤ 125. In contrast, PISNe become effective only for moderately metal-poor (Z < 8.0 × 10-3) VMSs. VMSs with mZAMS ≳ 220 M⊙ and Z < 10-3 do not undergo PISNe and form intermediate-mass BHs (with mass ≳200M⊙) via direct collapse.