Try convert the image to RGB:
...
new_p = Image.fromarray(fft_p)
if new_p.mode != 'RGB':
new_p = new_p.convert('RGB')
...
Try convert the image to RGB:
...
new_p = Image.fromarray(fft_p)
if new_p.mode != 'RGB':
new_p = new_p.convert('RGB')
...