If you want to get the good ending, during the final quest (Whatsoever a Man Soweth) you will have to face Gaunter O'Dimm - Master Mirror. However, this time it won't be a sword duel, but a riddle instead. You must get to the end of the road in the time limit. On the way you will find various solutions, from which none is correct. The key to victory is a fast run straight to the house on the hill which you will see from far away. There you will find the solution and thus win. On your way you will also find many opponents - phantoms that obtain some characteristics of monsters in which they transform. It's an impediment due to which you won't be able to use any oils, signs nor bombs which you would use when fighting regular versions of those monsters.
You can solve the riddle under one condition - if during the Whatsoever a Man Soweth... quest, before walking to the temple you, have completed the side objective about meeting with Shani and going to the professor of the Oxenfurt academy.
Turn right on the first crossroad, bypassing two enemies (probably the phantoms of drowners). On the next crossroad turn left and, after walking under the rocks, again left. After a while you will be attacked by a Leshen phantom - you can bypass it as well. Notice the red beam of light on the left side.
On the small rock you will find a sword in the rock. It is a good idea to pick it up as it's a unique sword from the Serpent School Gear - the Viper Venomous Silver Sword. Keep running on the road towards the mansion where you will face two more phantoms of gargoyles - you can avoid fighting with them as well. Enter the house. The ground of the corridor will collapse and you will fall down.
Once you're in the ruins, turn left immediately - you will notice one of the mirrors and a broken fountain there. Use the Witcher senses to examine the wall behind it and you will find the riddle solution. In order to finish this phase, simply destroy the wall with Aard sign.
As a reward for helping in defeating O'Dimm, Olgierd will give you one of the best swords in the game - Iris' saber. No matter which ending you have chosen, you will obtain the Pacta Sunt Servanda achievement/trophy.