Linksprite jpeg camera with SD Card

I am using the linksprite TTL jpeg camera with Arduino Due board, and Ethernet shield with SD Card. I used this code

except that I used tx1 and rx1, so instead of softwareserial, I used serial1. The data gets written to SD card, but If I try to open the pic from my laptop, it says file is broken. I tried to open with a picture viewer, chrome, none works.

Any hints on what I am doing wrong?