You can add the function that verify is data is None like:
image = Image.fromarray(arry)
if image is None: pass