Implement various handy functions.

This implements the two functions to read and write data using a buffer plus a function to peek at a byte at any position in the queue. This implementation is definitely not the most efficient and / or fast way to do it, but it works and it is able to act at least as a placeholder until a better solution is done.