Specify output directory from env

Also, make sure output directory exists and create it if necessary.

Signed-off-by: Francis Giraldeau <francis.giraldeau@gmail.com>