Stop DecodeImageMem memory leak

The `DecodeImageMem` function creates a header. This header needs to be freed before the return the image. The header wasn't being freed, so this function had a memory leak.