Code refactor and create edit images function

Created and modified functions for edit images and upload if it doesn't
exist