Add support for ZMQ 3.2, fix a few problems

Hi
I have been using parts of this code in another project, and as a result have been making changes to allow it to run with ZMQ 3.2, and fixing some minor memory issues (like the fact that the original code does not close messages).

Panda