OS X compatibility : add template to mktemp call
Switch from GNU getopt to Bash getopts