Line formation in solar granulation IV. (O I), O I and OH lines and the photospheric O abundance