The abundance and emission of H2O and O2 in clumpy molecular clouds