Added null check before storing image and changed image storage type to
png.