Fix bug where not enough pixels are returned