Added a method parameter for decide whether store image locally or not.