added some improvements

1. convert the canvas back to image
2. removed redundant code

Signed-off-by: tanji <nicholastanjerome@gmail.com>