Diphoton production at hadron colliders in NNLO QCD