public byte[] getOldImage(LogEntry entry) throws IOException
    {
        // @revised 0.24 BufferedImage => byte[]

        // check for type
        if (!entry.getType().equals(UPLOAD_LOG))
            throw new IllegalArgumentException("You must provide an upload log entry!");
        // no thumbnails for image history, sorry.
        String title = entry.getTarget();
        String url = query + "prop=imageinfo&iilimit=max&iiprop=timestamp%7Curl%7Carchivename&titles=File:" + title;
        String line = fetch(url, "getOldImage");

        // find the correct log entry by comparing timestamps
        while (line.contains("<ii "))
        {
            int a = line.indexOf("timestamp=") + 11;
            int b = line.indexOf('\"', a);
            String timestamp = convertTimestamp(line.substring(a, b));
            if (timestamp.equals(calendarToTimestamp(entry.getTimestamp())))
            {
                // this is it
                a = line.indexOf(" url=\"") + 6; // the space is important!
                b = line.indexOf('\"', a);
                url = line.substring(a, b);
                logurl(url, "getOldImage");
                URLConnection connection = new URL(url).openConnection();
                setCookies(connection);
                connection.connect();
                // there should be a better way to do this
                BufferedInputStream in = new BufferedInputStream(connection.getInputStream());
                ByteArrayOutputStream out = new ByteArrayOutputStream();
                int c;
                while ((c = in.read()) != -1)
                    out.write(c);

                // scrape archive name for logging purposes
                a = line.indexOf("archivename=\"") + 13;
                b = line.indexOf('\"', a);
                String archive = line.substring(a, b);
                log(Level.INFO, "Successfully retrieved old image \"" + archive + "\"", "getImage");
                return out.toByteArray();
            }
            line = line.substring(b + 10);
        }
        return null;
    }