Shell scripts bugfixes

* setup.sh: create the output dir if it doesn't exist
* make the scripts more sh compatible using $0 instead of
  $BASH_SOURCE[0]