Bafetimbi Gomis has secured European football for Marseille after scoring late on in their final Ligue 1 game against Bastia.