decode an image into an ndarray