Effects of compassion on the evolution of cooperation in spatial social dilemmas