improved saving of different types to the stream and fixed the resolution issue