*  local repository (i.e. not on Commons or deleted)
     *  @throws IOException if a network error occurs
     *  @throws IllegalArgumentException if the entry is not in the upload log
     *  @since 0.20
     */
    public byte[] getOldImage(Wiki.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=" + URLEncoder.encode(title, "UTF-8");
        String line = fetch(url, "getOldImage");

        // find the correct log entry by comparing timestamps
        // xml form: <ii timestamp="2010-05-23T05:48:43Z" user="Prodego" comment="Match to new version" />
        for (int a = line.indexOf("<ii "); a > 0; a = line.indexOf("<ii ", ++a))
        {
            String timestamp = convertTimestamp(parseAttribute(line, "timestamp", a));
            if (timestamp.equals(calendarToTimestamp(entry.getTimestamp())))
            {
                // this is it
                url = parseAttribute(line, "url", a);
                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
                String archive = parseAttribute(line, "archivename", 0);
                log(Level.INFO, "Successfully retrieved old image \"" + archive + "\"", "getImage");
                return out.toByteArray();
            }
        }
        return null;
    }