reimplement pgsave and pgpap