Revamped write_payload() and read_payload()

Restructured based on needing or not needing blank padding
Merge pull request #1 from zephyrr/master

Merge improved write_payload() and read_payload()  - looks good and passes my testing.