image.rb: support rack environment and make image_dir unless existent