Python: fixed writting out of memory.
Merge pull request #337 from shaitan/lts

Python: fixed writting out of memory.