Fixed bugs in binary PGM export and added option to do ASCII export.