BUGFIX: Fix filename generation

If output_dir is 'imgout' and the basename of f is 'img.png', then output_dir + f is 'imgoutimg.png' instead of 'imgout/img.png' as desired.