Create output directory if doesn't exist.

- move code to main.cc source file (used only for Flow123D not for unit
tests)