How about a little context of what you are trying to do?
I don't know what weird device you might be trying to control, so I'm a tiny bit short of 100% certain no form of conversion to hex is required before writing to its port. (That answers your explicit question).
Linux is a protected OS, so ordinary code can't ordinarily write to ports. So that is probably the source of the fault.
If you have done something to make writing to that port valid, that should have been part of the context you should have provided for your question.
If you haven't done anything to make writing to that port valid, here is the first link I found just now googling the topic:
It seems to be a good explanation of the basics.