added Decoder struct for decoding io.Reader