added jpg header and attempting to resist scale