afanasy: files are opened in binary mode, it became needed for thumnails