Revamped write_payload() and read_payload()

Restructured based on needing or not needing blank padding