Fixed some bugs and added some functionalities to support different image size (up to double of 1080x1919)