Implemented majority of the functions in KImage.js