fixed segfault in loading grayscale jpegs