Avoid out of memory problems

Backport of this patch:
http://git.infradead.org/mtd-utils.git/commit/71c76e74661492b4f68f670514866cfc85f47089
This avoids out of memory problems with ubiformat.