Is there any way of opening a file in binary mode?

When a user selects a file, I need to open it and read its contents. Then, if necessary, make changes to it and upload it to the server. Likewise, I need to be able to download a file, open it, make changes to it and save it to the user’s local disk. Is that at all possible?