fix maximum number of tile columns/rows check
fix: return NULL from peek_next_image when output buffer is empty