Offline path tracer produces a darker image than expected
I have found the issue. The gamma correction was the correct value, the same as in the book (1/2), but the light source had the brightness of 1.0f. The book had set the light's brightness to 18.0f for all color channels. 

This would introduce color overflow if left at that, and the very light areas (above 1.0f, and subsequently when converted, outside the range [0, 255]) would have wrong colors. 

To fix this clamp the the pixel's color values.


Go through all samples and calculate pixel color.
Divide the color by number of samples
Apply gamma correction
Clamp colors in range [0, 1]
Finally, convert values to range [0, 255]




(I will accept this answer as a solution in 2 days because StackExchange doesn't let me to do it now.)