Expose Flush API

This PR accomplishes two things:

1. Expose a flush API such that we have API similarity to Ruby's StringIO class.
2. Introduce fine grained locks which will make the system more reasonable.

These changes were primarily motivated by this issue: ryandotsmith/lpxc#7