Fixed image saving, added gamma correction where it is needed