fixes in image saving, threads and api