You're doing it fine. There is no reason to encode the file in any special format, and using hex for the output is pretty standard. The requirements, loosely speaking, are:
- the same document should always return the same ETag
- any changes in the document causes a change in ETag
- the ETag data should fit neatly into an HTTP header