Fix issues with saving image