implement resize function using PIL/Pillow