rewrite the converting part to do it page by page,

so we can avoid generating huge amount of temporary files in the process.