added saving image to disk and it works. inverting function not checked yet.