Fix thumbnailing and average image color calculation

This should resolve issue #6. I suspect that there's performance gains to be had by not converting to RGB in the average color calculation, but that's a future optimization.