Added generic message class

The class will be used to serialize and deserialize arbitrary messages.
The interface might be changed in case it makes sense to also pass in a socket (or file-like object)