Fixed packEcCoordinatesFromEcPoint variable-sized output

packEcCoordinatesFromEcPoint encoding numbers with a variable-sized format, causing deserialization to fail whenever either of the highest random byte of the public key points happened to come out 0. There were four chances for this to happen per call, so it's probably causing at least 1-(1-1/256)^4 ~= 1.5% of calls to fail.

The function also now checks the return codes of the OpenSSL functions for failures, and cleans up when exceptions occur. (Other code in the file also needs this change.)

Also included is a test which failed (consistently but not guaranteed) for the old code, and passes with the new code. It just runs 1000 ec25 key agreements.