How To Write A Binary Compress Function Python